﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;
using System.IO;
namespace Common
{
    
    public class ScoreHelper
    {
        public static IList<ScoreInfo> GetScoreList(string doc)
        {
            IList<ScoreInfo> scoreInfo = new List<ScoreInfo>();
            XmlDocument xmlDoc = new XmlDocument();
            if (PageValidate.IsEmpty(doc))
            {
                return null;
            }
            else
            {
                xmlDoc.LoadXml(doc);
            }
            XmlNode RootNode = xmlDoc.DocumentElement;
            XmlNodeList nodeList = RootNode.SelectNodes("Question");
            foreach (XmlNode node in nodeList)
            {
                scoreInfo.Add(new ScoreInfo
                {
                    Id = node.SelectSingleNode("Id").InnerText != "" ? int.Parse(node.SelectSingleNode("Id").InnerText.ToString()) : 0,
                    Score = node.SelectSingleNode("Score").InnerText.ToString(),
                    Answer = node.SelectSingleNode("Answer").InnerText.ToString()
                });
            }
            return scoreInfo;
        }
    }

    public class ScoreInfo
    {
        public int Id { get; set; }
        public string Score { get; set; }
        public string Answer { get; set; }
    }
}
